using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.RegularExpressions;

namespace DataModels.Models
{
    [Serializable]
    [Table("ANCForm")]
    public partial class ANCForm : MTUHAReportBase
    {
        //public int Id { get; set; }
        //public Nullable<int> MetadataId { get; set; }        
        //public string FacilityCode { get; set; }
        //public System.DateTime ReportDate { get; set; }

        //public bool LessThan20 { get; set; }

        private Nullable<int> _C_1;
        public Nullable<int> C_1 
        {
            get { return _C_1; }
            set
            {
                _C_1 = value;
                OnPropertyChanged("C_1");
            }
        }

        private Nullable<int> _C_3;
        public Nullable<int> C_3 
        {
            get { return _C_3; }
            set
            {
                _C_3 = value;
                OnPropertyChanged("C_3");
            }
        }

        private Nullable<int> _C_7;
        public Nullable<int> C_7
        {
            get { return _C_7; }
            set
            {
                _C_7 = value;
                OnPropertyChanged("C_7");
            }
        }

        private Nullable<int> _C_8;
        public Nullable<int> C_8
        {
            get { return _C_8; }
            set
            {
                _C_8 = value;
                OnPropertyChanged("C_8");
            }
        }

        private Nullable<int> _C_9;
        public Nullable<int> C_9
        {
            get { return _C_9; }
            set
            {
                _C_9 = value;
                OnPropertyChanged("C_9");
            }
        }

        private Nullable<int> _C_10;
        public Nullable<int> C_10
        {
            get { return _C_10; }
            set
            {
                _C_10 = value;
                OnPropertyChanged("C_10");
            }
        }

        public Nullable<int> HudhurioLaKwanza_2id { get; set; }

        public Nullable<int> VidokezoVyaHatari_4id { get; set; }

        public Nullable<int> PMTCT_5id { get; set; }

        public Nullable<int> Malaria_6id { get; set; }

        //public string Comments { get; set; }
        //public Nullable<int> Year { get; set; }
        //public Nullable<int> Month { get; set; }

        [ForeignKey("HudhurioLaKwanza_2id")]
        public ANCForm_HudhurioLaKwanza ANCForm_HudhurioLaKwanza { get; set; }

        [ForeignKey("Malaria_6id")]
        public virtual ANCForm_Malaria ANCForm_Malaria { get; set; }

        [ForeignKey("PMTCT_5id")]
        public virtual ANCForm_PMTCT ANCForm_PMTCT { get; set; }

        [ForeignKey("VidokezoVyaHatari_4id")]
        public virtual ANCForm_VidokezoVyaHatari ANCForm_VidokezoVyaHatari { get; set; }
        //public virtual ANCFormMetadata ANCFormMetadata { get; set; }
        //public virtual Facility Facility { get; set; }

        public static ANCForm Deserialize(string serializedObject)
        {
            // Remove any namespace attribute.
            string xmlnsPattern = "\\s+xmlns\\s*(:\\w)?\\s*=\\s*\\\"(?<url>[^\\\"]*)\\\"";
            serializedObject = Regex.Replace(serializedObject, xmlnsPattern, "");

            var deserializer = new System.Xml.Serialization.XmlSerializer(typeof(ANCForm));
            var reader = new System.IO.StringReader(serializedObject);
            using (var xmlReader = System.Xml.XmlReader.Create(reader))
            {
                if (deserializer.CanDeserialize(xmlReader))
                {
                    var e = deserializer.Deserialize(xmlReader) as ANCForm;
                    return e;
                }
                else return null;
            }
        }
    }
}
